package com.mzkj.wanjulaile.mobile.api.modules.account.controller;

import com.mzkj.common.data.StatusCode;
import com.mzkj.wanjulaile.mobile.api.common.controller.BaseController;
import com.mzkj.wanjulaile.mobile.api.common.entity.ResultEntity;
import com.mzkj.wanjulaile.mobile.api.modules.account.entity.Baby;
import com.mzkj.wanjulaile.mobile.api.modules.account.service.BabyService;
import com.mzkj.wanjulaile.mobile.api.modules.toy.entity.Toy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by meilein on 16/12/14.
 */
@RequestMapping("/baby")
@Controller
public class BabyController extends BaseController {
    @Autowired
    private BabyService babyService;

    /**
     * 未登录状态下宝宝推荐最贵的玩具
     *
     * @param
     * @return
     */
    @RequestMapping("/getBabyToyRecommend")
    @ResponseBody
    public ResultEntity<Map<String, Object>> getBabyToyRecommend() {
        ResultEntity<Map<String, Object>> result = new ResultEntity<>();
        Baby baby = null;
        Toy toy = new Toy();
        Map<String, Object> babyToy = new HashMap<String, Object>();
        try {
            //未登录 没有宝宝信息 按照玩具价格排序 显示8个最贵的
            babyToy = babyService.getRecommendNoBaby(baby, toy, babyToy);
            result.setData(babyToy);
            result.setStatusCode(StatusCode.SC0.getValue());
            result.setMsg(StatusCode.SC0.getDesc());
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            result.setStatusCode(StatusCode.SC5000.getValue());
            result.setMsg("获取宝宝推荐失败");
        }
        return result;
    }

}
